//
//  CellForMyTeam.m
//  MY Project For Sport
//
//  Created by dllo on 16/2/25.
//  Copyright © 2016年 dilo. All rights reserved.
//

#import "CellForMyTeam.h"
#import <SDWebImage/UIImageView+WebCache.h>
#import "ModelForMyTeam.h"


#define WEIGHTT [UIScreen mainScreen].bounds.size.width / 375
#define HEIGHTT [UIScreen mainScreen].bounds.size.height / 667


@interface CellForMyTeam ()
@property (nonatomic, retain) UIImageView *newsView;
@property (nonatomic, retain) UILabel *title;

@end

@implementation CellForMyTeam

- (void)dealloc {
    
    [_newsView release];
    [_title release];
    [super dealloc];

}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
      
        [self createSubView];
    }

    return self;
}

- (void)createSubView {

    self.newsView = [[UIImageView alloc] init];
    [self.contentView addSubview:self.newsView];
    [_newsView release];

    self.title = [[UILabel alloc] init];
    [self.contentView addSubview:self.title];
    [_title release];

}

- (void)layoutSubviews {
  
    [super layoutSubviews];
    
    self.newsView.frame = CGRectMake(5 * WEIGHTT, 5 * HEIGHTT, self.contentView.frame.size.width - 10 * WEIGHTT, self.contentView.frame.size.height - 10 * HEIGHTT);
    self.newsView.layer.cornerRadius = 15;
    self.newsView.layer.masksToBounds = YES;
   // self.newsView.backgroundColor = [UIColor redColor];
    
    
    self.title.frame = CGRectMake(20 * WEIGHTT, self.contentView.frame.size.height - 40 * HEIGHTT, self.contentView.frame.size.width - 40 * WEIGHTT, 30 * HEIGHTT);
    //self.title.backgroundColor = [UIColor yellowColor];
    
 
}

- (void)passModelForMyTeam:(ModelForMyTeam *)model {

    
    NSString *url = [model.img objectForKey:@"u"];
    
    [self.newsView sd_setImageWithURL:[NSURL URLWithString:url]];
    
    self.title.text = model.title;
    self.title.textColor = [UIColor whiteColor];
    self.title.font = [UIFont systemFontOfSize:15];

}


- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
